﻿CREATE PROCEDURE [dbo].[thuan_qtthemnguoidung]         
@MaNV as nvarchar(255),          
@TenNV as nvarchar(255),          
@DoUuTien as int,          
@MaPB as varchar(55),      
@ChuKy as image =null    ,             
@MaChucVu as int     
 
AS          
declare @dem as int           
select @dem=COUNT(*) from DanhMuc_NguoiDung where MaNV=@MaNV        
if(@dem >0)          
begin          
select ErrCode=0          
end          
else          
begin    
declare @MatKhau as nvarchar(50)
set @MatKhau=N'1'
 
      
insert into DanhMuc_NguoiDung(  
MaNV ,          
TenNV ,          
DoUuTien,          
MaPB ,                   
MaChucVu    ,      
ChuKy ,
MatKhau    
)values(  
@MaNV ,          
@TenNV ,          
@DoUuTien,          
@MaPB ,                   
@MaChucVu    ,      
@ChuKy ,
CAST(@MatKhau as varbinary(50))      
)     

select ErrCode=1          
end   
  